package com.ybkj.chat.module.main.fragment;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.ybkj.chat.R;
import com.ybkj.chat.base.BaseMvpFragment;
import com.ybkj.chat.manager.ActivityManager;
import com.ybkj.chat.module.dynamic.activity.AddFriendActivity;
import com.ybkj.chat.module.dynamic.activity.AddGroupActivity;
import com.ybkj.chat.module.dynamic.activity.CreatGroupActivity;
import com.ybkj.chat.module.friend_center.activity.MyQRcodeActivity;
import com.ybkj.chat.ui.adapter.MessageListAdapter;
import com.ybkj.chat.ui.dialog.PpwMessageMenu;
import com.ybkj.chat.ui.view.recyclerview.XRecyclerView;
import com.ybkj.chat.utils.ToastUtil;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 消息
 */
public class MessageFragment extends BaseMvpFragment {

    @BindView(R.id.message_search)
    ImageView messageSearch;
    @BindView(R.id.message_add)
    ImageView messageAdd;
    @BindView(R.id.search)
    RelativeLayout search;
    @BindView(R.id.message_content)
    XRecyclerView messageRecycle;

    private PpwMessageMenu mPpwMessageMenu;
    private MessageListAdapter mMessageListAdapter;

    @Override
    protected void injectPresenter() {

    }

    @Override
    protected void initView() {
        initRecycle();
        initPop();
    }

    private void initRecycle() {
        mMessageListAdapter = new MessageListAdapter(mContext);
        mMessageListAdapter.addData("1");
        mMessageListAdapter.addData("1");
        mMessageListAdapter.addData("1");
        mMessageListAdapter.addData("1");
        mMessageListAdapter.addData("1");
        messageRecycle.setAdapter(mMessageListAdapter);
        mMessageListAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                ToastUtil.showShort(position + "");
            }
        });
    }


    @Override
    protected void initData() {

    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_message;
    }

    @Override
    protected String getSimpleNme() {
        return null;
    }


    @OnClick({R.id.message_add, R.id.message_cancel})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.message_add:
                mPpwMessageMenu.showAsDropDown(messageAdd, 0, 0);
                mPpwMessageMenu.setBackgroundAlpha(mContext, 0.5f);
                break;
            case R.id.message_cancel:
                break;
        }
    }

    private void initPop() {
        mPpwMessageMenu = new PpwMessageMenu(mContext);
        mPpwMessageMenu.setOnMenuButtonCLickListener(new PpwMessageMenu.OnMenuButtonClickListener() {
            @Override
            public void onQrButtonClick() {

            }

            @Override
            public void onAddFriendButtonClick() {
                ActivityManager.gotoActivity(mContext, AddFriendActivity.class);
            }

            @Override
            public void onCreatGroupButtonClick() {
                ActivityManager.gotoActivity(mContext, CreatGroupActivity.class);

            }

            @Override
            public void onAddGroupButtonClick() {
                ActivityManager.gotoActivity(mContext, AddGroupActivity.class);
            }

            @Override
            public void onMyQrCodeButtonClick() {
                ActivityManager.gotoActivity(mContext, MyQRcodeActivity.class);

            }
        });
    }


}
